package com.jxtc.enterprise.admin.vo;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.jxtc.enterprise.hr.dto.OrderDetailDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

@Schema(description = "Admin 端订单管理页面订单详情信息")
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class AdminOrderDetailVO {

    @Schema(description = "订单 ID", example = "c752804d0cd410267f404dd3f0457a57")
    private String orderId;

    @Schema(description = "用户名", example = "张三")
    private String username;

    @Schema(description = "部门", example = "技术部")
    private String department;

    /**
     * TODO: 该字段的展示规则需要讨论
     */
    @Schema(description = "餐品名称", example = "小炒黄牛盖饭")
    private String orderName;

    @Schema(description = "价格，单位：元", example = "20")
    private Double price;

    @Schema(description = "下单时间", example = "2022-05-31 16:31:24")
    private String orderTime;

    /**
     * 订单备注信息
     */
    private String note;

    public AdminOrderDetailVO(OrderDetailDTO dto) {
        this.orderId = dto.getOrderId();
        this.username = dto.getUsername();
        this.department = dto.getDepartmentName();
        this.price = dto.getTotalAmount() / 100.0;
        this.orderTime = LocalDateTimeUtil.format(dto.getOrderTime(), DatePattern.NORM_DATETIME_PATTERN);
    }
}
